﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IceCS.DesignPattern.Core.StrategyPattern.ShopStrategy
{
    /// <summary>
    /// 返现策略
    /// </summary>
    public class CashReturn : CashBase
    {
        private decimal _moneyCondition;
        private decimal _moneyReturn;
        public CashReturn(decimal moneyCondition, decimal moneyReturn)
        {
            _moneyCondition = moneyCondition;
            _moneyReturn = moneyReturn;
        }

        public override decimal AcceptCash(decimal money)
        {
            if (money >= _moneyCondition)
            {
                return money - Math.Floor(money / _moneyCondition) * _moneyReturn;
            }
            else
            {
                return money;
            }
        }
    }
}
